#pragma once

#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QOpenGLShader>
#include <QOpenGLShaderProgram>
#include <QOpenGLBuffer>
#include <QOpenGLTexture>

#include <QObject>
#include <QUdpSocket>
#include <cmath>
#include <array>
#include <fstream>

class UdpReceiver : public QObject
{
    Q_OBJECT
public:
    explicit UdpReceiver(std::vector<std::string> udpPorts, QObject *parent = nullptr);
    void subscribe(void *pManager);
    void unsubscribe(void *pManager);
signals:
    void messageReceived(const QByteArray &message);

public slots:
    void startListening(quint16 port);
    void stopListening();
private slots:
    void processPendingDatagrams();

private:
    QUdpSocket *udpSocket;
    void *pManager_{nullptr};
    QList<QUdpSocket *> sockets_;
    std::vector<int> ports_;
};